
<template>
  <div class="index-box" ref="index">
    <div class="backBox">
        <span class="back" @click="back"><i class="el-icon-back"></i>返回</span>
    </div>
    <div class="shop-box">
      <div class="d-flex">
        <div class="left">
        <el-form  :model="form" size="small" ref="form" label-width="140px" class="form" :rules="rules">
          <el-card class="box-card">
          	<div slot="header" class="clearfix">
          		<span class="headerTitle">基础信息</span>
          	</div>
          	<div class="text item">
              <el-descriptions class="margin-top" title="" :column="3" :size="size">
                <el-descriptions-item label="商品类目">{{form.goodsCategoryName}}</el-descriptions-item>
                <el-descriptions-item label="商品编号">{{form.goodsCode}}</el-descriptions-item>
                <el-descriptions-item label="商品标题">{{form.goodsName}}</el-descriptions-item>
                <el-descriptions-item label="所属商品组">{{form.columnNames}} </el-descriptions-item>
                <el-descriptions-item label="标签" v-if="tagList.length"><el-tag type="success" v-for="item in tagList" :style="{borderColor:item.color,color: item.color}" style="margin-right:10px">{{item.name}}</el-tag></el-descriptions-item>
              </el-descriptions>
              <el-descriptions class="margin-top" title="重要属性" :column="3" :size="size" v-if="form.brandName || form.netContent">
                <el-descriptions-item label="品牌" v-if="form.brandName">{{form.brandName}}</el-descriptions-item>
                <el-descriptions-item label="产品净含量" v-if="form.netContent">{{form.netContent}}</el-descriptions-item>
              </el-descriptions>
              <el-descriptions class="margin-top" title="其他属性" :column="3" :size="size" v-if="form.otherAttribute">
                <el-descriptions-item label="产地" v-if="form.otherAttribute.placeOfOrigin">{{form.otherAttribute.placeOfOrigin}}</el-descriptions-item>
                <el-descriptions-item label="保质期" v-if="form.otherAttribute.shelfLife">{{form.otherAttribute.shelfLife}}</el-descriptions-item>
                <el-descriptions-item label="生产企业" v-if="form.otherAttribute.manufacturingEnterprise">{{form.otherAttribute.manufacturingEnterprise}}</el-descriptions-item>
                <el-descriptions-item label="毛重" v-if="form.otherAttribute.roughWeight">{{form.otherAttribute.roughWeight}}</el-descriptions-item>
                <el-descriptions-item label="条形码" v-if="form.otherAttribute.barCode">{{form.otherAttribute.barCode}}</el-descriptions-item>
                <el-descriptions-item label="用途" v-if="form.otherAttribute.purpose">{{form.otherAttribute.purpose}}</el-descriptions-item>
              </el-descriptions>

          	</div>
          </el-card>
          <el-card class="box-card">
          	<div slot="header" class="clearfix">
          		<span class="headerTitle">图文信息</span>
          	</div>
          	<div class="text item">
              <el-descriptions class="margin-top" title="" :column="1" :size="size">
                <el-descriptions-item label="主  图">
                  <div class="d-flex">
                  	<el-image :src="form.goodsImage" fit="fill" v-image-preview="form.goodsImage"
                  		style='height:100px;cursor: pointer;border: 1px dashed #d9d9d9;'></el-image>
                      <el-image :src="item" fit="fill" v-image-preview="item" v-for="item in form.imgDetails"
                      	style='height:100px;cursor: pointer;border: 1px dashed #d9d9d9;margin: 0 10px'>
                      </el-image>
                  </div>
                </el-descriptions-item>
                <el-descriptions-item label="商品详情" contentClassName="shdt">
                  <div style="height:720px;width:100%">
                    <quill-editor v-model="form.goodsDetails" ref="myQuillEditor" class="myQuillEditor"
                    	disabled></quill-editor>
                  </div>

                </el-descriptions-item>
              </el-descriptions>
          	</div>
          </el-card>

          <el-card class="box-card">
          	<div slot="header" class="clearfix">
          		<span class="headerTitle">价格库存</span>
          	</div>
          	<div class="text item">
              <el-descriptions class="margin-top" title="" :column="3" :size="size">
                <el-descriptions-item label="发货模式" >{{form.shipmentAddress=='1'?'现货发货模式':'不发货模式'}}</el-descriptions-item>
                <el-descriptions-item label="发货地" v-if="form.shipmentAddress=='1'">{{form.productAddress}}</el-descriptions-item>
                <el-descriptions-item label="发货时间" v-if="form.shipmentAddress=='1'">
                  <span v-if="form.shipmentsTimeType=='1'">次日发</span>
                  <span v-if="form.shipmentsTimeType=='2'">48小时发</span>
                  <span v-if="form.shipmentsTimeType=='3'">当日发</span>
                </el-descriptions-item>
              </el-descriptions>

              <el-descriptions class="margin-top" title="" :column="1" :size="size">
                <el-descriptions-item label="商品规格" >
                  <div class="d-flex flex-wrap">
                    <div v-for="(item1,index1) in ruleList" class="rows" >
                    	<el-input v-model="item1.name" class="input" placeholder="参数名称" disabled />:
                    	<el-input v-model="item.val" class="input" v-for="(item,index) in item1.child"
                    		placeholder="参数值" disabled></el-input>
                    </div>
                  </div>

                </el-descriptions-item>
              </el-descriptions>
              <el-descriptions class="margin-top moneyBox" title="" :column="1" :size="size">
                <el-descriptions-item label="价格与库存" >
                  <div style="width:100%;overflow-x: auto;">
                    <table border="1" cellspacing="0">
                    	<tr>
                    		<th v-for="item in ruleList">{{item.name}}</th>

                    		<th><span class="red">*</span>供货价(元)
                    		</th>
                    		<th><span class="red">*</span>平台售价(元)
                    		</th>
                    		<th style="width:250px"><span class="red">*</span>原价(元)

                    		</th>
                    		<th><span class="red">*</span>库存(件)

                    		</th>
                    		<th>单位

                    		</th>
                    		<th>商家编码

                    		</th>
                    	</tr>
                    	<template v-for="(item,index2) in dataList">
                    		<tr>
                    			<td v-for="(item1,index1) in ruleList">{{item['name'+index1]}}</td>
                    			<td>
                    				{{item.costPrice}}元
                    			</td>
                    			<td>
                    				{{item.sellingPrice}}元
                    			</td>
                    			<td>{{item.nameoriginal}}元</td>
                    			<td>
                    				{{item.inventory}}
                    			</td>
                    			<td>
                    				{{item.unit}}
                    			</td>
                    			<td>
                    				{{item.code}}
                    			</td>
                    		</tr>
                    	</template>
                    </table>

                  </div>
                </el-descriptions-item>
              </el-descriptions>


          		<!--	<p class="red margin0">{{tableTips}}</p>-->
          		</el-form-item>
          	</div>
          </el-card>

          <el-card class="box-card">
          	<div slot="header" class="clearfix">
          		<span class="headerTitle">服务与履约</span>
          	</div>
          	<div class="text item">
              <el-descriptions class="margin-top" title="" :column="1" :size="size">
                <el-descriptions-item label="运费模板">包邮</el-descriptions-item>
              </el-descriptions>
              <el-descriptions class="margin-top sh" title="" :column="1" :size="size">
                <el-descriptions-item label="售后服务">
                  <span v-for="(item,index) in afterSalesServiceList" v-if="afterSalesService.length && afterSalesService.indexOf(item.id)!='-1'" style="padding-right:10px">{{index+1}}.{{item.name}}</span>
                  <el-input type="textarea" v-model="afterSalesServiceElse" placeholder="偏远地区如(新疆,西藏,青海,受疫区)不予发货" v-if="afterSalesServiceElse"></el-input>
                </el-descriptions-item>
              </el-descriptions>
              <el-descriptions class="margin-top" title="商品限购" :column="2" :size="size" v-if="form.totalPurchaseRestriction || form.oncePurchaseRestriction">
                <el-descriptions-item label="单用户累计限购" v-if="form.totalPurchaseRestriction">{{form.totalPurchaseRestriction}}件</el-descriptions-item>
                <el-descriptions-item label="单用户累计限购" v-if="form.oncePurchaseRestriction">{{form.oncePurchaseRestriction}}件</el-descriptions-item>
              </el-descriptions>

          	</div>
          </el-card>

          <el-card class="box-card">
          	<div slot="header" class="clearfix">
          		<span class="headerTitle">好礼专区配置</span>
          	</div>
          	<div class="text item">
              <div class="goodSet">
               <!-- <div class="title">好礼专区配置</div> -->
                <div class="box d-flex align-center">
                  <div class="label" style="margin-right:15px"><span class="red">*</span>消费券抵扣</div>
                  <div class="content">
                    <el-input v-model="user.couponPrice" clearable size="small"></el-input>
                  </div>
                </div>
                <div class="box" style="padding: 20px 0">
                    备注：平台售价-消费券抵扣 = 实际付款价格
                </div>
                <div class="box d-flex">
                   <div class="label" style="margin-right:15px"><span class="red">*</span>好店专区是否显示</div>
                   <div class="content">
                     <el-radio-group v-model="user.goodStoreShow">
                         <el-radio label="1">是</el-radio>
                         <el-radio label="2">否</el-radio>
                       </el-radio-group>
                   </div>
                </div>
                 <div class="title" style="text-align: left;margin-top:15px;font-weight: bold;">好礼专区推荐位</div>
                 <div class="box boxs">
                   <el-checkbox-group v-model="checkedCities">
                     <el-checkbox v-for="city in cities" :label="city.id" :key="city.id">{{city.name}}</el-checkbox>
                   </el-checkbox-group>
                   <div class="banner d-flex" v-if="checkedCities=='3'">
                       <div class="label" style="margin-right:15px;color:#606266;width:120px;text-align: center;"><span class="red">*</span>上传Banner</div>
                       <div class="content flex1">
                         <MyUpImg :imagePreview='user.bannerImage' :imageSource='imageSource' @change="imageChange" size="700"></MyUpImg>
                         <p class="red">图片规格为：宽 700px、高230px、尺寸不能超过10mb</p>
                         <p >备注：上传Banner图时，一定要按照图片的规格大小和图片展现的方式制作，您可右击下载 图片进行参考，上传的图若造成平台负面影响，仟店平台会下架您的商品并追究相关责任。</p>
                       </div>
                   </div>
                 </div>
              </div>
            <!--  <div class="goodSet" >
                <div class="title" style="text-align: left;">好礼专区推荐位</div>
                <div class="box boxs">
                  <el-radio-group
                    v-model="checkedCities">
                    <el-radio v-for="city in cities" :label="city.id" :key="city.id">{{city.name}}</el-radio>
                  </el-radio-group>
                  <div class="banner d-flex" v-if="checkedCities.includes('3')">
                      <div class="label" style="margin-right:15px;color:#606266;width:120px;text-align: center;"><span class="red">*</span>上传Banner</div>
                      <div class="content flex1">
                        <MyUpImg :imagePreview='user.bannerImage' :imageSource='imageSource' @change="imageChange" size="700"></MyUpImg>
                        <p class="red">图片规格为：宽 700px、高230px、尺寸不能超过10mb</p>
                        <p >备注：上传Banner图时，一定要按照图片的规格大小和图片展现的方式制作，您可右击下载 图片进行参考，上传的图若造成平台负面影响，仟店平台会下架您的商品并追究相关责任。</p>
                      </div>
                  </div>
                </div>
              </div> -->
          	</div>
          </el-card>

          <div class="right">

          </div>
        </el-form>
        </div>

      </div>
    </div>
    <div class="activeBox">
      <el-button type="primary" @click="submit()"  :loading="loading2">修改</el-button>
    </div>
  </div>
</template>

<script>
  import { getGoodsDetail,goodsInfo,releaseGoods,goodsCategoryList,applyHotGoods } from '@/api/getData';
  import Treeselect from "@riophae/vue-treeselect";
  import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  import common from "@/api/api";
  import { regionData,CodeToText } from 'element-china-area-data';

  import { quillEditor } from "vue-quill-editor"; //调用编辑器
  import 'quill/dist/quill.core.css';
  import 'quill/dist/quill.snow.css';
  import 'quill/dist/quill.bubble.css';

  export default {
    name:'shopDetails',
    components: { Treeselect,quillEditor },
    data() {
      return {
        loading: false,
        loading1:false,
        loading2:false,
        size:'small',
        loginUserlevelId:'',//登录用户的等级  为1普通会员不显示好礼专区
        cascaderOptions:regionData,/*省市区插件数据*/
        deptOptions:[],
        /*上传图片参数*/
        actionUrl:common.apihost+"/system/file/uploadFile",
        header:{
          Authorization:''
        },

        imagePreview: '',
        imageSource: '',
        /*上传图片参数*/
        parameterList:[{name:'',child:[{val:''}]}],
        ruleList:[{name:'',child:[{val:'',key:''}]}],
        dataList:[],//列表数据
        tagList:[],
        form:{
          goodsCategoryId:undefined,//商品类别ID
          goodsCode:'',//商品编号
          goodsName:'',//商品名称
          brandName:'',//品牌
          netContent:'',//产品净含量
          otherAttribute:{//其他属性-json串
            placeOfOrigin:'',//产地
            shelfLife:'',//保质期
            manufacturingEnterprise:'',//生产企业
            roughWeight:'',//毛重
            barCode:'',//条形码
            purpose:'',//目的地
          },

          shipmentsTimeType:'1',//发货时间类型：1：次日发 2：48小时发 3：当日发
          afterSalesService:{},//售后服务-json串
          totalPurchaseRestriction:'',//累计限购（件）
          oncePurchaseRestriction:'',//单次限购（件）
          goodsImage:'',// 封面图片
          attachmentIds:[],//  多张图片
          imgDetails:[],
          guarantee:'',//  保障说明
          paramsJson:'',//  参数JSON串
          provinceId:'',//  省ID
          cityId:'',//  市ID
          areaId:'',// 区ID
          productAddress:'',//  发货地（省市区名称）
          goodsDetails:'',//  商品详情
          goodsType:'1',//  商品类型：1好礼 2好店   动态的
          couponPrice:'',//  消费券抵扣金额
          couponFlag:'',//  新会员赠送消费券是否可用 1不可用 2可用
          hotFlag:'',//  爆品推荐 1是 2否
          productFlag:'',//  产品推荐 1是 2否
          bannerImag:'',//e  banner图(好礼才有）

          auditState:'',// 审核状态 1草稿 2待审核 3已通过 4已驳回

          addr:'',
        },
        afterSalesService:{},
        afterSalesServiceList:[{id:'1',name:'坏损包退'},{id:'2',name:'正品保障'},{id:'3',name:'假一赔四'},{id:'4',name:'订单完成15天内售后保障'},{id:'5',name:'其他'}],
        afterSalesServiceElse:"",
        editMoney:{/*表格价格统一编辑按钮*/
          nameoriginal:'',
          costPrice:'',
          sellingPrice:'',
          inventory:'',
          code:'',
          visible1:false,
          visible2:false,
          visible3:false,
          visible4:false,
          visible5:false,
        },
        rules: {
          // goodsCategoryId: [{required: true, message: '请选择商品分类',trigger: 'blur'}],
          // goodsName: [{required: true, message: '请输入商品名称',trigger: 'blur'}],
          // goodsImage: [{required: true, message: '请上传商品图片',trigger: 'blur'}],
          // attachmentIds: [{required: true, message: '请上传商品详情图',trigger: 'blur'}],
          // guarantee: [{required: true, message: '请输入保障',trigger: 'blur'}],
          // addr: [{required: true, message: '请选中发货地',trigger: 'blur'}],
          // goodsDetails: [{required: true, message: '请输入商品详情',trigger: 'blur'}],
          // paramsJson: [{required: true, message: '请输入参数',trigger: 'blur'}],
          // rule: [{required: true, message: '请输入规则',trigger: 'blur'}],
          // ruleSet: [{required: true, message: '请输入规则配置',trigger: 'blur'}],
        },

        checkedCities:[],
        cities:[{name:'好礼广告位(展位)',id:'3'}],
        radio:1,
        active:1,
        user:{
          bannerImage:'',
          couponFlag:'2',//1不可用 2可用
          goodStoreShow:'2',//好店专区是否显示  1是 2否
          couponPrice:'',
          goodsId:'',
          hotFlag:'',
          productFlag:''
        },
      }
    },
    mounted() {
      this.header.Authorization = localStorage.getItem('appToken');
      this.statusId = this.$route.query.id;
      this.form.goodsType = this.$route.query.goodsType;
      this.getTree();

      if(this.$route.query.goodsId){
        this.editDataInfo(this.$route.query.goodsId);
      }
      this.loginUserlevelId = this.$route.query.levelId;

    },
    methods: {

      editDataInfo(goodsId){
        getGoodsDetail({goodsId:goodsId}).then((result) => {
          if (result.code == 200) {
              let goodsInfoDto = result.data.goodsInfoDto;
              this.form.goodsCategoryId = goodsInfoDto.productCategoryId;
              this.tagList = result.data.tagList?result.data.tagList:[];
              this.form.goodsCode = goodsInfoDto.goodsCode;
              this.form.goodsName = goodsInfoDto.goodsName;
              this.form.goodsImage = goodsInfoDto.goodsImage;
              let imgDetails = [];
              let attachmentIds = [];
              for(let i=0;i<result.data.attachmentInfoList.length;i++){
                imgDetails.push(result.data.attachmentInfoList[i].fullFilename)
                attachmentIds.push(result.data.attachmentInfoList[i].attachmentId)
              }

               this.form.brandName = goodsInfoDto.brandName;
               this.form.netContent = goodsInfoDto.netContent;
               this.form.otherAttribute = JSON.parse(goodsInfoDto.otherAttribute)?JSON.parse(goodsInfoDto.otherAttribute):{ placeOfOrigin:'',shelfLife:'',manufacturingEnterprise:'',roughWeight:'',barCode:'',purpose:''};
               this.form.shipmentsTimeType = goodsInfoDto.shipmentsTimeType+'';
               this.form.totalPurchaseRestriction = goodsInfoDto.totalPurchaseRestriction;
               this.form.oncePurchaseRestriction = goodsInfoDto.oncePurchaseRestriction;
               this.afterSalesService = JSON.parse(goodsInfoDto.afterSalesService)?JSON.parse(goodsInfoDto.afterSalesService).selectObj:[];
               this.afterSalesServiceElse = JSON.parse(goodsInfoDto.afterSalesService)?JSON.parse(goodsInfoDto.afterSalesService).afterSalesServiceElse:'';


              this.form.imgDetails = imgDetails;
              this.form.attachmentIds = attachmentIds;
              this.form.goodsDetails = JSON.parse(goodsInfoDto.goodsDetails);
              this.form.guarantee = goodsInfoDto.guarantee;
              this.form.provinceId = goodsInfoDto.provinceId;
               this.form.shipmentAddress = goodsInfoDto.shipmentAddress
              if(goodsInfoDto.shipmentAddress=='1'){
                this.form.cityId = goodsInfoDto.cityId;
                this.form.areaId = goodsInfoDto.areaId;
                this.form.productAddress = goodsInfoDto.productAddress;
                this.form.addr = [(goodsInfoDto.provinceId).substring(0,6),(goodsInfoDto.cityId).substring(0,6)];
              }
              // this.form.cityId = goodsInfoDto.cityId;
              // this.form.areaId = goodsInfoDto.areaId;
              // this.form.productAddress = goodsInfoDto.productAddress;
              // this.form.addr = [(goodsInfoDto.provinceId).substring(0,6),(goodsInfoDto.cityId).substring(0,6)];
              // parameterList:[{name:'',child:[{val:''}]}],
              // ruleList:[{name:'',child:[{val:'',key:''}]}],
              // dataList:[],//列表数据

              let ruleList = [];
              for(let i=0;i<result.data.specKeyList.length;i++){
                let obj = {name:result.data.specKeyList[i].specName,child:[]};
                for(let a=0;a<result.data.specKeyList[i].specValueList.length;a++){
                  obj.child.push({val:result.data.specKeyList[i].specValueList[a].specValueName})
                }
                ruleList.push(obj);
              }
              this.ruleList = ruleList;

              let parameterList = [];
              let parameterListUrl = JSON.parse(goodsInfoDto.paramsJson);
              for(let i =0;i<parameterListUrl.length;i++){
                parameterList.push({name:parameterListUrl[i].name,child:[{val:parameterListUrl[i].val}]})
              }
              this.parameterList = parameterList;

              let dataList = [];
              let skuStockList = result.data.skuStockList;
              for(let i =0;i<skuStockList.length;i++){
                dataList.push({
                  name0:skuStockList[i].specNameOne,
                  name1:skuStockList[i].specNameTwo,
                  name2:skuStockList[i].specNameThree,
                  nameoriginal:skuStockList[i].originalPrice,
                  costPrice:skuStockList[i].costPrice,
                  sellingPrice:skuStockList[i].salePrice,
                  inventory:skuStockList[i].stockNum,
                  code:skuStockList[i].cargoNo,
                  unit:skuStockList[i].unit})
              }
              this.dataList = dataList;


              /*好礼专区配置*/
              this.user.couponFlag = goodsInfoDto.couponFlag;
              this.user.bannerImage = goodsInfoDto.bannerImage;
              this.user.couponPrice = goodsInfoDto.couponPrice;
              this.user.goodStoreShow = goodsInfoDto.goodStoreShow+'';

              if(goodsInfoDto.bannerImage){
              	this.checkedCities = ['3'];
              }
              if(goodsInfoDto.hotFlag=='1'){
              	this.checkedCities = [];
              }
              if(goodsInfoDto.productFlag=='1'){
              	this.checkedCities = [];
              }

          } else {
            this.$message.error(result.msg);
          }
        });
      },
      submit() {/*申请提额提交*/
        let data = {
          bannerImage:this.user.bannerImage,
          couponFlag:this.user.couponFlag,//1不可用 2可用
          couponPrice:this.user.couponPrice,
          goodStoreShow:this.user.goodStoreShow,
          goodsId:this.$route.query.goodsId,
          hotFlag:this.checkedCities.includes('1')?'1':'2',
          productFlag:this.checkedCities.includes('2')?'1':'2',
          bannerFlag :this.checkedCities.includes('3')?'1':'2'//好礼banner显示
        }
        this.loading2 = true;
        applyHotGoods(data).then(res=>{
          console.log(res)
          if(res.code == 200){
               this.$message.success(res.msg);
               setTimeout(res=>{
                 this.$router.go(-1);
               },2000)
          }else{
             this.$message.error(res.msg);
          }
           this.loading2 = false;
        })
      },
      reset(){
        this.parameterList = [{name:'',child:[{val:''}]}];
        this.ruleList = [{name:'',child:[{val:'',key:''}]}];
        this.dataList = [];
        this.resetForm("form");
      },
      async getTree() {
        try {
          const result = await goodsCategoryList({storeId:this.$route.query.storeId});
          if (result.code == 200) {
            this.deptOptions = result.data
          } else {
            this.$message.error(result.msg);
          }
        } catch (err) {
          console.log(err)
        }
      },
      normalizer(node) {
        if (node.children && !node.children.length) {
          delete node.children;
        }
        return {
          id: node.categoryId,
          label: node.name,
          children: node.children
        };
      },
       tagDeltVal(parentIndex,index,type){
          if(type=='params'){
             this.parameterList[parentIndex].child.splice(index,1);
          }else{
            this.ruleList[parentIndex].child.splice(index,1);
          }
          this.dataInfo();
       },
       tagAddVal(parentIndex,type){
         if(type=='params'){
            this.parameterList[parentIndex].child.push({val:''})
         }else{
            this.ruleList[parentIndex].child.push({val:''})
         }
        this.dataInfo();
       },
      TagDeltRow(index,type){/*删除当前行*/
        if(type=='params'){
          this.parameterList.splice(index,1);
        }else{
            this.ruleList.splice(index,1);
        }
        this.dataInfo();
      },

      addressChange(arr) {
          console.log(arr);
          console.log(CodeToText[arr[0]], CodeToText[arr[1]], CodeToText[arr[2]]);
          this.form.provinceId = arr[0]+'000000';
          this.form.cityId = arr[1]+'000000';
          this.form.areaId = arr[2]+'000000';
          this.form.productAddress = CodeToText[arr[0]] + CodeToText[arr[1]] + CodeToText[arr[2]]
      },
      dataInfo(){/*表格计算*/
        let attrValue = [];// [['红', '黄', '蓝']['1', '3', '4']]
        for(let i=0;i<this.ruleList.length;i++){
          let arr = [];
          for(let a=0;a<this.ruleList[i].child.length;a++){
            arr.push(this.ruleList[i].child[a].val)
          }
          attrValue.push(arr)
        }
        let finalArr = this.cartesianProductOf(...attrValue);
        console.log(finalArr);

        let list = [];
        for(let i=0;i<finalArr.length;i++){
          let obj = {nameoriginal:'0',costPrice:'0',sellingPrice:'0',inventory:'0',code:'0',unit:''}
          for(let a=0;a<finalArr[i].length;a++){
            obj['name'+a] =finalArr[i][a];
          }
          list.push(obj)
        }
        this.dataList = list;
        console.log(list);

      },
      handleSureEditMoney(val,label,visible){/*批量修改价钱*/
        for(let i=0;i<this.dataList.length;i++){
          this.dataList[i][label] = val;
        }
        this.editMoney[visible] = false;
      },
      //递归树结构
      recursiveTree(tree) {
      	//格式化：清掉空的children，将title换成label
          tree.map(item => {
              item.label = item.categoryName;
              item.id = item.categoryId;
              if (item.children) {
                  item.children.map(child => {
                      child.label = child.categoryName;
                      child.id = child.categoryId;
                  });
                  this.recursiveTree(item.children);
              } else {
                  delete item.children
              }
          })
          return tree;
       },
      // 笛卡尔积算法
      cartesianProductOf(...args) {
        return args.reduce(
          (total, current) => {
            let ret = []
            total.forEach((a) => {
              current.forEach((b) => {
                ret.push(a.concat([b]))
              })
            })
            return ret
          },
          [[]]
        )
      },
      tagAddRow(type){
        if(type=='params'){
          if(this.parameterList.length=='5'){
            this.$modal.msgError('最多添加五行');
            return;
          }
          this.parameterList.push({name:'',child:[{val:''}]})
        }else{
          if(this.ruleList.length=='3'){
            this.$modal.msgError('最多添加三行');
            return;
          }
          this.ruleList.push({name:'',child:[{val:''}]})
        }
        this.dataInfo();
      },

      imageChange(path) {
        this.user.bannerImage = path;
      },
      handleAvatarSuccess(res, file) {
        if(res.code==200){
          this.form.attachmentIds.push(res.data.attachmentId);
          this.form.imgDetails.push(res.data.fullFilename)
        }else{
          this.$message.error('上传失败')
        }
      },
       handleRemove(index) {
       this.form.attachmentIds.splice(index, 1);
       this.form.imgDetails.splice(index, 1);
      },
      handleExceed(files, fileList) {
        this.$message.warning(`当前限制选择 4 个图片，本次选择了 ${files.length} 个文件，共选择了 ${files.length + fileList.length} 个文件`);
      },
       beforeAvatarUpload(file) {
        const is1M = file.size / 1024 / 1024 < 10; // 限制小于10M
          if (!is1M) {
              this.$message.error('图片尺寸限制最小为750 x 750，大小不可超过10MB，比例为1:1');
              return false;
          } else {
              const isSize = new Promise((resolve, reject) => {
                  const width = 750;
                  const height = 750;
                  const _URL = window.URL || window.webkitURL;
                  const img = new Image();
                  img.onload = () => {
                      const valid = img.width >= width && img.height >= height && img.width === img.height;
                      valid ? resolve() : reject();
                  };
                  img.src = _URL.createObjectURL(file);
              }).then(
                  () => {
                      return file;
                  },
                  () => {
                      this.$message.error('图片尺寸限制最小为750 x 750，大小不可超过10MB，比例为1:1');
                      return Promise.reject();
                  },
              );
              return isSize;
          }
      },
      back(){
          this.$router.go(-1);//返回上一层
      },
      up(){/*上一条*/

      },
      audit(){/*审核*/

      },
      next(){/*下一条*/

      }
    }
  }
</script>

<style scoped lang="scss">
  .left /deep/ .shdt{
    flex:1
  }
   .index-box /deep/ .el-descriptions__header{
    margin-bottom: 10px;
  }
  .index-box /deep/ .el-descriptions__header .el-descriptions__title{
    font-size: 14px;
  }
  .tableBox /deep/ .el-form-item__content{
    width:100%;
    overflow-x: auto;
  }
  .shop-box /deep/ .el-form-item__label{
    padding:0px;
  }
  .miniTips{
    font-size: 12px;
    color:#CCC4CC;
    padding-left:4px;
    display:none;
  }
  .box-card{
    margin-bottom: 15px;
  }
  .headerTitle{
    font-size: 16px;
    font-weight: bold;
  }
  .moneyBox /deep/ .el-descriptions-item__content{
  	flex:1;
  }
  .left /deep/ td{
  	padding:10px 5px;
  	font-size: 14px;
  }
  .activeBox{
    display:flex;
    justify-content:center;
  }
  .upGoodBox{
    height:100px;
    display:flex;
    align-items:center;
    justify-content: center;
    background: rgba(158, 187, 169, 0.15);
    color:#3A7654;
    margin-bottom:20px;
  }

  .el-checkbox-group{
    display: flex;
    flex-direction: column;
  }
  .jobNumber{
    text-align:center;
    color:#606266;
    margin:0;
  }
  .index-box /deep/ .el-checkbox{
    margin-bottom:15px;
  }
  .boxs /deep/ .el-radio-group{
  	display: flex;
  	flex-wrap: wrap;
  }
  .boxs /deep/ .el-radio-group .el-radio{
  	width:100%;
  	margin-bottom: 10px;
  }
  .auditBox{
    padding: 20px 50px;
    background: rgba(158, 187, 169, 0.15);
    margin-bottom:20px;
    .steps{
      max-width:500px;
      margin:0 auto;
    }
  }
  .goodSet{
    padding: 50px 50px 30px 50px;
    background: rgba(158, 187, 169, 0.15);
    margin-bottom:20px;
    color:#606266;
    .title{
      text-align: center;
      font-size:18px;
      margin-bottom:20px;
    }
  }
  .el-icon-edit-outline{
    color: rgb(97, 153, 122);
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
  }
  .myQuillEditor{
    height:665px;
  }
  table {
    width: 100%;
  }

  th {
    height: 50px;
    text-align: left;
    border-bottom: 1px solid #EBEEF5!important;
    color:#909399;
    padding:0 5px;

  }
  table{
    border: 1px solid #EBEEF5;
  }
  td, th{
    border:none;
    white-space: nowrap;
    min-width: 80px;
  }
  td{padding:5px}
  .index-box{
    height:100%;
    overflow-y: auto;
  }
  .shop-box{
    margin: 0 auto;
    .left{
      width:75%;
      padding:0 10px;
      margin:auto;
    }
    .right{
      width:100%;
      padding:0 10px;
    }
  }
  .rows>div,.rows>button{
    margin-bottom: 5px;
  }
  .input{
    width:180px;
    margin-right:10px;
  }
  .form{
    padding:20px 0;
  }
   .form /deep/ .avatar-uploader .el-upload-list__item{display: none;}
  .avatar-uploader{
      border: 1px dashed #d9d9d9;
      border-radius: 6px;
      cursor: pointer;
      position: relative;
      overflow: hidden;
      height:100px;
      width:100px;
    }
    .avatar-uploader .el-upload:hover {
      border-color: #409EFF;
    }
    .avatar-uploader-icon {
        height: 30px;
        line-height: 30px;
        margin-top: 15px;
        margin-bottom: 10px;
        font-size: 28px;
        color: #8c939d;
    }
    .d-flex /deep/ .el-upload{
      display: block;
    }
    .avatar {
      width: 100px;
      height: 100px;
      display: block;
    }
    .text{
      margin: 0px;
      color: #8c939d;
    }
    .upImg /deep/ .el-upload--text{
      height:100%
    }
    .activeBox{
      display: flex;
      justify-content: center;
    }
    .el-upload-list--picture-card .el-upload-list__item{
        width:100px;
        height:100px;
    }
</style>
